package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ProduceScheduling;
import com.dragon.repository.entity.SchedulingSon;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProduceSchedulingDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "生产表id")
    private String produceId;

    @ApiModelProperty(value = "生产状态：1生产中2生产完成")
    private Integer type;

    @ApiModelProperty(value = "开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date startTime;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "设备编号")
    private Integer equipmentCode;

    @ApiModelProperty(value = "设备图片")
    private Integer equipmentImg;

    @ApiModelProperty(value = "设备状态 0空闲 1生产中")
    private Integer equipmentType;

    @ApiModelProperty(value = "排产子表")
    private List<SchedulingSon> schedulingSonList;


    public ProduceSchedulingDTO() {}

    public ProduceSchedulingDTO(ProduceScheduling entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ProduceSchedulingDTO convert(ProduceScheduling entity) {
        return new ProduceSchedulingDTO(entity);
    }

    public static List<ProduceSchedulingDTO> convertList(List<ProduceScheduling> list) {
        List<ProduceSchedulingDTO> resultList = new ArrayList<>();
        for (ProduceScheduling entity : list) {
            resultList.add(new ProduceSchedulingDTO(entity));
        }
        return resultList;
    }}
